1. /* sdftansr.cpp by K.Tsuru */
  2. // function ID 3106 DRADIX
  3. /********************************
  4. SDouble class
  5. It provides the tangent tan x.
  6. Old version's name is "SDouble Tan(const SDouble& x)".
  7. *********************************/
  8. #ifndef SN_H
  9. #include "sn.h"
  10. #endif
  11. SDouble TanRN(const SDouble& x){
  12. if(x.Sign(3106) == 0) return 0.0;
  13. int sgn, func = TAN_CALC;
  14. SDouble s, c, r;
  15. sgn = GetTriCalcMethod(x, r, &func); // |r| < pi/4
  16. //When tan(x) has an infinite value the domain error will occur in GetTriCalcMethod(x,r,&func);
  17. if(sgn == 0) return 0.0;
  18. // tan(r) = sin(r)/cos(r)
  19. if(r.NetRdxExp() < -1){ // |x| < 1/DRADIX^2
  20. s = SinSeries(r);
  21. c = CosRN(r);
  22. } else{
  23. RealSize C;
  24. uint up = s.ProperUpPrec(2u);
  25. if(up) C.SetEffFig(x.EffFig() + up, C.TEMP_EXTEND);
  26. s = SinRN(r); // |r| < pi/4 , |s| < sqrt(0.5)
  27. c = Sqrt(1.0-s*s);
  28. if(up) C.SetEffFig(0);
  29. }
  30. if(func == TAN_CALC) r = s*DReciprocal(c);
  31. else r = c*DReciprocal(s); // cot x
  32. if(sgn < 0) r.ChangeSign(); // r = -r;
  33. return r;
  34. }

sdftanrn.cpp : last modifiled at 2015/06/03 15:17:11(1,058 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).